import { createRouter, createWebHistory } from 'vue-router'
import registerEach from './permission'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login.vue')
    },
    {
      path: '/',
      redirect: '/home',
      component: () => import('@/layout/index.vue'),
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/index.vue')
        },
        {
          path: '/power/menu',
          name: 'menu',
          component: () => import('@/views/power/menu/index.vue')
        },
        {
          path: '/bill/manage',
          name: 'billManage',
          component: () => import('@/views/bill/manage/index.vue')
        },
        {
          path: '/bill/card',
          name: 'billCard',
          component: () => import('@/views/bill/card/index.vue')
        },
        {
          path: '/bill/payType',
          name: 'payType',
          component: () => import('@/views/bill/payType/index.vue')
        },
        {
          path: '/bill/variation',
          name: 'billVariation',
          component: () => import('@/views/bill/variation/index.vue')
        }
      ]
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'notFound',
      component: () => import('@/views/404/index.vue')
    }
  ]
})

registerEach(router)

export default router
